import {getOrderInfo} from '../../service/order'
import {orderStatus} from '../../utils/data'

Page({

    /**
     * 页面的初始数据
     */
    data: {
        orderStatus,
        order: {},
        orderDetails: [],
        address: {},
        loading: true,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        const order_id = options.order_id
        getOrderInfo(order_id).then(order => {
            this.setData({
                order,
                orderDetails: order.orderDetails.data,
                address: order.address,
                loading: false
            })
        })
    },

    /**
     * 支付订单
     */
    payOrder() {
        // 获取子组件对象
        const payDialog = this.selectComponent('#pay-dialog')
        // 调用子组件方法, 弹出支付二维码
        payDialog.getPayQrcode(this.data.order.id)
        
    }
})